<?php
namespace api\user\validate;

use think\Validate;

class ChangeTraderPasswordValidate extends Validate
{
    protected $rule = [
            'trader_password'   => 'require|checkTraderPassword',
            'confirm_trader_password'   => 'require|confirm:trader_password',
            // 'verification_code' => 'require|checkVerificationCode'
    ];
    protected $message = [
            'trader_password.require'   => '请输入您的新交易密码',
            'confirm_trader_password.require'   => '请确认新交易密码',
            'confirm_trader_password.confirm'  => '两次交易密码不一致',
            // 'verification_code.require' => '请输入验证码'
    ];

    protected $scene = [
    ];

    protected function checkTraderPassword($value, $rule, $data)
    {
        if (preg_match('/^\d{6}$/', $value)){
            return true;
        }else{
            return '交易密码格式不正确';
        }
    }

    protected function checkVerificationCode($value, $rule, $data)
    {
        if (preg_match('/^\d{6}$/', $value)){
            return true;
        }else{
            return '验证码格式不正确';
        }
    }
}